{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy.stats import norm as gaussian"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Probability Density Function\n",
    "- PDF a.k.a. Probability Distribution Density Function\n",
    "- Probabiliy of $x$ between $a$ and $b$ for any $(a,b)$ is\n",
    "\n",
    "> $\\displaystyle P_{ab} = \\int_a^b p(x)\\,dx$\n",
    "\n",
    "- Always \n",
    "\n",
    "> $\\displaystyle  \\int_{-\\infty}^{\\infty} p(x)\\,dx = 1$\n",
    "\n",
    "\n",
    "- Example 1: uniform distribution on $(a,b)$\n",
    "\n",
    "> $\\displaystyle  U(x;a,b) = \\frac{\\pmb{1}_{ab}(x)}{b\\!-\\!a} $,\n",
    "> where $\\pmb{1}_{ab}(x)$ is 1 between $a$ and $b$, but 0 otherwise\n",
    "\n",
    "- Example 2: Gaussian or normal distribution\n",
    "\n",
    "> $\\displaystyle  G(x;\\mu,\\sigma) = \\frac{{1}}{\\sqrt{2\\pi\\sigma^2}}\\ \\exp\\left[{-\\frac{(x\\!-\\!\\mu)^2}{2 \\sigma^2} }\\right]$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cummulative Distribution Function\n",
    "- Integral up to given $x$: prob of being less than $x$\n",
    "\n",
    "> $\\displaystyle \\mathrm{CDF}(x) = \\int_{-\\infty}^{x} p(t)\\,dt$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Characterization of PDFs\n",
    "\n",
    "- Expectation value of $X$\n",
    "\n",
    "> $\\displaystyle \\mu = \\mathbb{E}[X] = \\int_{-\\infty}^{\\infty}\\! x\\ p(x)\\,dx$\n",
    "\n",
    "- Expectation value of any $f(X)$\n",
    "\n",
    "> $\\displaystyle \\mathbb{E}[f(X)] = \\int_{-\\infty}^{\\infty}\\! f(x)\\,p(x)\\,dx$\n",
    "\n",
    "- Moments \n",
    "\n",
    "> $\\displaystyle \\mathbb{E}[X^k]$\n",
    "    \n",
    "- Central moments \n",
    "\n",
    "> $\\displaystyle \\mathbb{E}\\big[(X\\!-\\!\\mu)^k\\big]$\n",
    "\n",
    "- Variance\n",
    "\n",
    "> $\\displaystyle \\mathbb{Var}[X] = \\mathbb{E}\\big[(X\\!-\\!\\mu)^2\\big]$\n",
    "\n",
    "- Standard deviation\n",
    "\n",
    "> $\\displaystyle \\sigma = \\sqrt{\\mathbb{Var}[X]}$\n",
    "\n",
    "- Normalized moments\n",
    "\n",
    "> $\\displaystyle \\mathbb{E}\\left[\\left(\\frac{X\\!-\\!\\mu}{\\sigma}\\right)^k\\right]$\n",
    "\n",
    "- Skewness\n",
    "\n",
    "> 3rd normalized moment ($k$=3)\n",
    "\n",
    "- Kurtosis\n",
    "\n",
    "> 4th normalized moment ($k$=4)\n",
    " "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src=\"http://www.astroml.org/_images/fig_kurtosis_skew_1.png\" width=400 align=left>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0, 2, array(0.), array(4.), array(0.), array(0.))"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mu, sig = 0, 2\n",
    "mean, var, skew, kurt = gaussian.stats(mu, sig, moments='mvsk');\n",
    "mu, sig, mean, var, skew, kurt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Density Estimation\n",
    "- Histograms\n",
    "    - Width of bins, $h$\n",
    "    - Start of bin boundary, $x_0$\n",
    "\n",
    " >$\\displaystyle \\mathrm{Hist}(x) = \\frac{1}{N}\\sum_i \\pmb{1}_{\\mathrm{bin}(x_i;x_0,h)}(x)$\n",
    "        \n",
    "- Kernel Density Estimation (KDE)\n",
    "    - Bandwidth $h$\n",
    "   \n",
    " >$\\displaystyle \\mathrm{KDE}(x) = \\frac{1}{N}\\sum_i K_h(x\\!-\\!x_i) = \\frac{1}{Nh}\\sum_i K\\left(\\frac{x\\!-\\!x_i}{h}\\right)$\n",
    "   \n",
    "    - Can use different $K(\\cdot)$ kernel functions\n",
    "        - E.g., Uniform, Triangular, Gauss, Epanechnikov\n",
    "\n",
    "See animations at\n",
    "http://www.mglerner.com/blog/?p=28"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Kernel Function\n",
    "- Finite vs Infinite support\n",
    "- Numerical evaluations\n",
    "- Frequently used kernels\n",
    "\n",
    "<img src=\"https://upload.wikimedia.org/wikipedia/commons/4/47/Kernels.svg\" alt=\"All of the above kernels in a common coordinate system\"  width=\"350\" align=left>\n",
    "\n",
    "Learn more about KDE \n",
    "[here](https://jakevdp.github.io/blog/2013/12/01/kernel-density-estimation/) and also check out Bayesian Blocks \n",
    "[here](https://jakevdp.github.io/blog/2012/09/12/dynamic-programming-in-python/)\n",
    "<br>\n",
    "&mdash; tutorials by Jake Vanderplas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Detour: Dirac delta\n",
    "\n",
    "- In the limit of $h\\rightarrow{}0$, the kernel will become strange:\n",
    "\n",
    "<img src=\"https://upload.wikimedia.org/wikipedia/commons/4/48/Dirac_distribution_PDF.svg\" align=right width=250>\n",
    "\n",
    "> **Dirac's $\\delta$** \"function\" is 0 everywhere except at 0 such that\n",
    "\n",
    "> $\\displaystyle \\int \\delta(x)\\,dx = 1$\n",
    "\n",
    "- Interesting properties, e.g., \n",
    "\n",
    "> $\\displaystyle \\int f(x)\\,\\delta(x\\!-\\!a)\\,dx = f(a)$\n",
    "\n",
    "-  See **distribution theory** and **functionals** for more background"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### An interesting result \n",
    "\n",
    "- Bad density estimation but if...\n",
    "\n",
    "> $\\displaystyle p(x) = \\frac{1}{N} \\sum_{i=1}^N \\delta(x\\!-\\!x_i)$\n",
    "\n",
    "- The expectation value\n",
    "\n",
    "> $\\displaystyle \\mathbb{E}[X] =  \\int x\\, \\frac{1}{N} \\sum_{i=1}^N  \\delta(x\\!-\\!x_i) \\,dx$\n",
    "\n",
    "> $\\displaystyle \\mathbb{E}[X] = \\frac{1}{N} \\sum_{i=1}^N \\int x\\, \\delta(x\\!-\\!x_i) \\,dx$\n",
    "\n",
    "> $\\displaystyle \\mathbb{E}[X] = \\frac{1}{N} \\sum_{i=1}^N x_i$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Excercise\n",
    "\n",
    "0. Sample from a mixture of two Gaussians using uniform random numbers in the [0,1) interval. Try different $(\\mu_1, \\sigma_1)$ and $(\\mu_2,\\sigma_2$) values!\n",
    "0. Build different density estimators and compare to the original PDF. Try histogramming and KDE with different parameters."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from scipy.stats import norm as gaussian\n",
    "from scipy.stats import uniform as uni\n",
    "from scipy import stats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 1.,  0.,  0.,  0.,  1.,  1.,  2.,  0.,  4.,  3.,  5.,  5.,  3.,\n",
       "        12., 11., 17., 14., 12., 18., 28., 28., 30., 38., 46., 25., 34.,\n",
       "        30., 44., 39., 47., 35., 28., 38., 47., 24., 24., 24., 26., 15.,\n",
       "        14., 19., 15., 11., 17.,  8., 10.,  8.,  6.,  7., 10.,  4.,  2.,\n",
       "         7.,  3.,  7.,  3.,  6.,  9.,  7.,  9.,  4.,  5.,  3.,  2.,  3.,\n",
       "         1.,  6.,  6.,  1.,  3.,  3.,  2.,  1.,  1.,  0.,  1.,  1.,  1.,\n",
       "         3.,  3.,  2.,  0.,  0.,  0.,  0.,  4.,  0.,  0.,  0.,  0.,  1.,\n",
       "         0.,  0.,  0.,  0.,  1.,  0.,  0.,  0.,  1.]),\n",
       " array([-3.24126734, -3.12445128, -3.00763523, -2.89081917, -2.77400311,\n",
       "        -2.65718706, -2.540371  , -2.42355494, -2.30673889, -2.18992283,\n",
       "        -2.07310677, -1.95629072, -1.83947466, -1.7226586 , -1.60584255,\n",
       "        -1.48902649, -1.37221043, -1.25539438, -1.13857832, -1.02176226,\n",
       "        -0.90494621, -0.78813015, -0.67131409, -0.55449804, -0.43768198,\n",
       "        -0.32086592, -0.20404987, -0.08723381,  0.02958225,  0.14639831,\n",
       "         0.26321436,  0.38003042,  0.49684648,  0.61366253,  0.73047859,\n",
       "         0.84729465,  0.9641107 ,  1.08092676,  1.19774282,  1.31455887,\n",
       "         1.43137493,  1.54819099,  1.66500704,  1.7818231 ,  1.89863916,\n",
       "         2.01545521,  2.13227127,  2.24908733,  2.36590338,  2.48271944,\n",
       "         2.5995355 ,  2.71635155,  2.83316761,  2.94998367,  3.06679972,\n",
       "         3.18361578,  3.30043184,  3.41724789,  3.53406395,  3.65088001,\n",
       "         3.76769606,  3.88451212,  4.00132818,  4.11814423,  4.23496029,\n",
       "         4.35177635,  4.4685924 ,  4.58540846,  4.70222452,  4.81904057,\n",
       "         4.93585663,  5.05267269,  5.16948874,  5.2863048 ,  5.40312086,\n",
       "         5.51993691,  5.63675297,  5.75356903,  5.87038509,  5.98720114,\n",
       "         6.1040172 ,  6.22083326,  6.33764931,  6.45446537,  6.57128143,\n",
       "         6.68809748,  6.80491354,  6.9217296 ,  7.03854565,  7.15536171,\n",
       "         7.27217777,  7.38899382,  7.50580988,  7.62262594,  7.73944199,\n",
       "         7.85625805,  7.97307411,  8.08989016,  8.20670622,  8.32352228,\n",
       "         8.44033833]),\n",
       " <a list of 100 Patch objects>)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQIC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hTVS8A30hy0bDqSuDJJZY0q68DlyV53fCzdyVb6CCvI/TJ/Anwo8ADa99LvlhVv7nckibT8JINlwM3AV9O8viw7v3DLGZtDb8F3DEMIJ4Bfm3J9Uytqh5OchfwKGtt18fYQjNGnSkqSU3YcpGkJgx0SWrCQJekJgx0SWrCQJekJgx0SWrCQJekJgx0SWri/wDs3A2t6FAZmQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Traditional Method\n",
    "mu1, sigma1, n1 = 3, 2, 200\n",
    "mu2, sigma2, n2 = 0, 1, 800\n",
    "np.random.seed(seed=42)\n",
    "x = gaussian.rvs(mu1,sigma1,n1)\n",
    "y = gaussian.rvs(mu2,sigma2,n2)\n",
    "z = np.hstack([x,y])\n",
    "plt.hist(z,bins=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([ 1.,  2.,  2.,  6.,  1.,  6.,  6.,  6.,  8., 15., 19., 17., 20.,\n",
       "        24., 23., 24., 33., 32., 35., 32., 35., 45., 45., 40., 43., 46.,\n",
       "        29., 36., 35., 33., 25., 28., 19., 17., 14., 11., 14.,  8.,  5.,\n",
       "        12.,  5.,  5.,  8.,  5., 11.,  3.,  6.,  5.,  4.,  3.,  4.,  4.,\n",
       "         4., 10.,  6.,  6.,  6.,  4.,  1.,  2.,  4.,  4.,  1.,  2.,  1.,\n",
       "        12.,  0.,  2.,  1.,  1.,  0.,  4.,  1.,  0.,  1.,  0.,  1.,  4.,\n",
       "         1.,  2.,  0.,  0.,  0.,  2.,  0.,  0.,  0.,  0.,  0.,  0.,  1.,\n",
       "         0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  1.]),\n",
       " array([-2.72467263, -2.6025164 , -2.48036018, -2.35820395, -2.23604772,\n",
       "        -2.1138915 , -1.99173527, -1.86957904, -1.74742281, -1.62526659,\n",
       "        -1.50311036, -1.38095413, -1.25879791, -1.13664168, -1.01448545,\n",
       "        -0.89232923, -0.770173  , -0.64801677, -0.52586054, -0.40370432,\n",
       "        -0.28154809, -0.15939186, -0.03723564,  0.08492059,  0.20707682,\n",
       "         0.32923304,  0.45138927,  0.5735455 ,  0.69570172,  0.81785795,\n",
       "         0.94001418,  1.06217041,  1.18432663,  1.30648286,  1.42863909,\n",
       "         1.55079531,  1.67295154,  1.79510777,  1.91726399,  2.03942022,\n",
       "         2.16157645,  2.28373268,  2.4058889 ,  2.52804513,  2.65020136,\n",
       "         2.77235758,  2.89451381,  3.01667004,  3.13882626,  3.26098249,\n",
       "         3.38313872,  3.50529495,  3.62745117,  3.7496074 ,  3.87176363,\n",
       "         3.99391985,  4.11607608,  4.23823231,  4.36038853,  4.48254476,\n",
       "         4.60470099,  4.72685721,  4.84901344,  4.97116967,  5.0933259 ,\n",
       "         5.21548212,  5.33763835,  5.45979458,  5.5819508 ,  5.70410703,\n",
       "         5.82626326,  5.94841948,  6.07057571,  6.19273194,  6.31488817,\n",
       "         6.43704439,  6.55920062,  6.68135685,  6.80351307,  6.9256693 ,\n",
       "         7.04782553,  7.16998175,  7.29213798,  7.41429421,  7.53645043,\n",
       "         7.65860666,  7.78076289,  7.90291912,  8.02507534,  8.14723157,\n",
       "         8.2693878 ,  8.39154402,  8.51370025,  8.63585648,  8.7580127 ,\n",
       "         8.88016893,  9.00232516,  9.12448139,  9.24663761,  9.36879384,\n",
       "         9.49095007]),\n",
       " <a list of 100 Patch objects>)"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwO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/iC3MY5lTVy8A3klw8HLoKeGaGJa3W14HLk7xp+B67ijkc3F3iIWDPsL0HeHDUE9q20Ef4I+CHgYOL/+98uap+bbYljdZouYUrgJuBryZ5cjj2kWHmsWbj14G7h4bC88Avz7ieFauqR5PcDzzOYlfqE8zJrNEk9wDvBs5LchT4XWAfcF+SW4AXgfeO/Dzz09sgSTqdTdnlIkkdGeiS1ISBLklNGOiS1ISBLklNGOiS1ISBLklNGOiS1MT/AKaEOKC+CEYxAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Inverse Transform\n",
    "U = uni.rvs(size=200)\n",
    "x = gaussian.ppf(U, mu1, sigma1)\n",
    "U = uni.rvs(size=800)\n",
    "y = gaussian.ppf(U, mu2, sigma2)\n",
    "z = np.hstack([x,y])\n",
    "plt.hist(z,bins=100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD8CAYAAACb4nSYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3Xt0VPW99/H3N3cuBkJIwiVAuEuQACEiCl4RRatildbL8RGvVFuetqun61TbLj0HV3tO7eVpe0qrtHiq1taqT6tU8QJys2qQhAQwXEMIJCGEQCDhEhKSfJ8/ZoZniAmZkJnZc/m+1srKzN6/veeTncl3dn77t/cWVcUYY0x0iHE6gDHGmOCxom+MMVHEir4xxkQRK/rGGBNFrOgbY0wUsaJvjDFRxIq+McZEESv6xhgTRazoG2NMFIlzOkB7AwcO1KysLKdjGGNMWCksLDysqmldtQu5op+VlUVBQYHTMYw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Y0wUsaJvjDFRxIq+McZEESv6xhgTRazoG2NMFPl/mnw+ptFmCKIAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#KDE\n",
    "kernel=stats.gaussian_kde(z)\n",
    "xx = np.linspace(-7,10,201)\n",
    "kdepdf = kernel.evaluate(xx)\n",
    "plt.plot(xx, kdepdf, color=\"g\")\n",
    "plt.show()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
